/**
 * Copyright (c) 2009-2011, chunquedong(YangJiandong)
 * 
 * This file is part of ChunMap project
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
 * 
 * History:
 *     2010-05-05  Jed Young  Creation
 */
package chunmap.view.render;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;

/**
 * @author chunquedong
 * 
 */
public class Painter {

	private Image image;
	private Graphics2D g;
	private int width;
	private int height;

	public Painter(int width, int height) {
		reset(width, height);
	}

	public void reset(int width, int height) {
		this.width = width;
		this.height = height;
		image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		g = (Graphics2D) image.getGraphics();
		setBackground(Color.white);
	}

	public void setBackground(Color c) {
		g.setBackground(c);
	}

	public void clear() {
		g.clearRect(0, 0, width, height);
	}

	public Image getData() {
		image.flush();
		return image;
	}
	
	public Graphics2D getGraphics(){
		return g;
	}
}